package vn.gq.udv.utils;

import vn.gq.tym.storytemplate.GQConst;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;

public class ButtonHelper {
	
	private Context context;
	
	public ButtonHelper(Context context) {
		this.context = context;
	}
	
	public void showMoreApp() {
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		builder
			.setMessage("CHỌN KHO ỨNG DỤNG !")
			.setPositiveButton("UNG DUNG VIET", new DialogInterface.OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int which) {
					try {
						context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(GQConst.SEARCHURI_UNGDUNGVIET)));
					} catch (ActivityNotFoundException e) {
						try {
							context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/search?q=pub:UNGDUNGVIET&c=apps&sort=1")));
						} catch(Exception ex) {
							Toast.makeText(context, "Không có ứng dụng Google Play trong máy", Toast.LENGTH_SHORT).show();
						}
					}
				}
			})
			.setNegativeButton("TRUYEN HAY VIET", new DialogInterface.OnClickListener() {
				
				@Override
				public void onClick(DialogInterface dialog, int which) {
					try {
						context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(GQConst.SEARCHURI_TRUYENHAYVIET)));
					} catch (ActivityNotFoundException e) {
						try {
							context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/search?q=pub:LOCXOAY&c=apps&sort=1")));
						} catch(Exception ex) {
							Toast.makeText(context, "Không có ứng dụng Google Play trong máy", Toast.LENGTH_SHORT).show();
						}
					}
				}
			})
			.create()
			.show();
	}
}
